export let backEnd = {
    namespaced: true,
    state: {
        zipData: null,
    },
    actions: {
        PostZipData(store, data = {}) {
            let url = "/blacklist/zip";
            let formData = new FormData();
            formData.append('zip', data.zip);
            return new Promise((resolve, reject) => {
                axios.post(url, formData, {
                    headers: {
                        'Content-Type': 'multipart/form-data'
                    }
                }).then(({
                    data
                }) => {
                    store.commit('setZipData', data);
                    resolve(data);
                }).catch((error) => {
                    if (error.response) {
                        // 请求已发出，但服务器响应的状态码不在 2xx 范围内
                        reject(error.response.data)
                    }
                });
            });
        },
    },
    mutations: {
        setZipData(state, data = {}) {
            state.zipData = data;
        },
    }
}